<template>
	<view class="finance-nav-box" :style="'padding-top:'+(barHeight)+'px'">
		<NavBar left-icon="plusempty" @onLeftIcon="add">
			<template v-slot:center>
				<view class="nav_center">
					<view class="navActive">财务管理</view>
				</view>
			</template>
		</NavBar>
		<view class="scroll-box">
			<scroll-view class="control" :scroll-x="true" :show-scrollbar="false">
				<view class="control_scroll">
					<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
						activeColor="#007aff"></uni-segmented-control>
				</view>
			</scroll-view>
		</view>
		<view class="content">
			<view v-if="current == 0">
				<PayList></PayList>
			</view>
			<view v-if="current == 1">
				<QuoteList></QuoteList>
			</view>
			<view v-if="current == 2">
				<SaleContractList></SaleContractList>
			</view>
			<view v-if="current == 3">
				<ProcureContractList></ProcureContractList>
			</view>
			<view v-if="current == 4">
				<ExpenseList></ExpenseList>
			</view>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import PayList from './PayList.vue'
	import QuoteList from './QuoteList.vue'
	import SaleContractList from './SaleContractList.vue'
	import ProcureContractList from './ProcureContractList.vue'
	import ExpenseList from './ExpenseList.vue'
	export default {
		components: {
			NavBar,
			PayList,
			QuoteList,
			SaleContractList,
			ProcureContractList,
			ExpenseList
		},
		data() {
			return {
				items: ['支付申请', '报价管理', '销售合同', "采购合同", "报销管理"],
				current: 0,
				barHeight: 0, // 手机导航栏高度
			}
		},
		onReachBottom() {
			if (this.current == 0) {

			} else if (this.current == 1) {
				uni.$emit('onReachBottomQuote')
			} else if (this.current == 2) {
				uni.$emit('onReachBottomSaleContract')
			} else if (this.current == 3) {
				uni.$emit('onReachBottomProcureContract')
			} else if (this.current == 4) {
				
			}
		},
		created() {
			this.barHeight = uni.getSystemInfoSync().statusBarHeight + 45;
		},
		// 子组件请求
		beforeMount() {
			uni.$on('financeList', (e) => {
				this.current = e
			})
		},
		destroyed() {
			uni.$off('financeList')
		},
		methods: {
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			},
			add() {
				if (this.current == 0) {
					uni.$emit('addPay')
				} else if (this.current == 1) {
					uni.$emit('addQuote')
				} else if (this.current == 2) {
					uni.$emit('addSaleContract')
				} else if (this.current == 3) {
					uni.$emit('addProcureContract')
				} else if (this.current == 4) {
					uni.$emit('addExpense')
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '../../static/css/commons.css';
	@import '../../static/css/FinanceNav.css';
</style>
